package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import lombok.*;

import java.util.HashMap;
import java.util.Map;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class Strategy extends BaseDomain {
    public static final int STATE_NORMAL = 0; // 正常
    public static final int STATE_PUSH = 1; //推荐
    public static final int STATE_BAN = 2; // 禁用

    private Region place; // 地区

    private String title; // 标题

    private String subTitle; // 副标题

    private String coverUrl; // 背景图片

    private Integer state = STATE_NORMAL; // 状态

    //页面数据 回显
    public String getJsonString(){
        Map<String,Object> map  = new HashMap<>();
        map.put("id",getId());
        if(place != null){
            map.put("placeId",place.getId());
        }
        map.put("title",title);
        map.put("subTitle",subTitle);
        map.put("coverUrl",coverUrl);
        map.put("state",state);
        return JSONUtil.toJSONString(map);
    }

    // 页面状态回显
    public String getStateDisplay(){
        if(state == null){
            return "";
        }
        if(state == STATE_NORMAL){
            return "正常";
        }else if(state == STATE_PUSH){
            return "推荐";
        }else if(state == STATE_BAN){
            return "禁用";
        }
        return "";
    }

}